
package vv.lines.view.swing;

import java.awt.Graphics;
import java.awt.Image;

/**
 *
 * @author vpotapenko
 */
public abstract class SwingImageObjectView extends SwingFieldItem {

    private Image paintImage;

    public void setImage(Image paintImage) {
        this.paintImage = paintImage;
    }

    public Image getImage() {
        return paintImage;
    }

    @Override
    protected void paintObject(Graphics g) {
        if (paintImage != null) paintObjectWithImage(g);
        else paintObjectWithoutImage(g);
    }

    protected void paintObjectWithImage(Graphics g) {
        g.drawImage(paintImage, getX(), getY(), getWidth(), getHeight(), null);
    }

    protected abstract void paintObjectWithoutImage(Graphics g);
}
